layui.use(['form', 'jquery', 'uploads','common','mycomm'], function () {
		let form = layui.form;
		let $ = layui.jquery;
		let common = layui.common;
		let mycomm = layui.mycomm;

		layer.ready(function(){
			getStaffList();
			resize_group_width();
		});
		
		$('#staff-btn').bind('click', function() {
			$('#staff dl').fadeIn();
			getStaffList();
		})
	
		//员工搜索框动画效果
		$('#search_input').bind('focus', function() {
			$('#staff dl').fadeIn();
		}).bind('blur', function() {
			$('#staff dl').fadeOut();
		}).bind('keydown', function(e) {
			if(e.keyCode == "13") {
				getStaffList();
				return false;
			}
		});		
		
	   //加载员工列表
	   function getStaffList(){
		   let val = $('#search_input').val();
		   let url= $('#search_input').attr('url');
		   let data={key:val};
		   let $box = $('#staff');
		   let $list = $('#staff dl');
		   mycomm.post(url,data,function(res){
			    $list.html('');
				if(res.data!=undefined){
					for(var i in res.data){
					  if(res.data[i]!=undefined){
						   $list.append("<dd data-id='" + res.data[i].id + "'>" + res.data[i].name + "</dd>");
					  }
					};
				}else{
					$list.append("<dd>【无匹配的用户信息】</dd>");
				}
				
				$('#staff dd').bind('click',function() {
					var id=$(this).data('id');
					if(id!=undefined){
						$('#search_input').val($(this).html());
						$('[name=cusid]').val(id);
						$list.fadeOut();
					}
				});
		   });
	   }
	   
	   //改变窗口同步宽度
	   $(window).resize(function() {
			resize_group_width();
	   });
	   
	   function resize_group_width(){
		   $('#staff dl').width($('#search_input').width()+10);
	   }	   

	})